package com.zmn.plat.services.impl.message;

import java.util.Objects;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.common.utils.number.NumberUtil;
import com.zmn.plat.model.entity.message.MsgAliTemplate;
import com.zmn.plat.persistence.interfaces.message.MsgAliTemplateDAO;
import com.zmn.plat.services.interfaces.message.MsgAliTemplateService;

import lombok.extern.slf4j.Slf4j;

/**
 * 描述: 基础接口实现类
 *
 * @author tanghongjun
 * @since 2020-06-19 15:34:59
 **/
@Slf4j
@Service
public class MsgAliTemplateServiceImpl implements MsgAliTemplateService {

    private static final String TAG = "基础服务接口";

    @Resource
    private MsgAliTemplateDAO msgAliTemplateDao;

    /**
     * 描述: 根据id查询数据
     *
     * @param msgAliTemplateId
     *            id
     * @author tanghongjun
     * @since 2020-06-19 15:34:59
     **/
    @Override
    public MsgAliTemplate findById(Integer msgAliTemplateId) {

        if (Objects.isNull(msgAliTemplateId)) {
            log.error("[{}],根据id查询数据msgAliTemplateId为null", TAG);
            return null;
        }
        return msgAliTemplateDao.findById(msgAliTemplateId);
    }

    @Override
    public MsgAliTemplate findByTemplateId(Integer templateId) {

        if (NumberUtil.isNullOrZero(templateId)) {
            return null;
        }
        return msgAliTemplateDao.findByTemplateId(templateId);
    }

    /**
     * 描述: 根据id修改数据 id为必传
     *
     * @param msgAliTemplate
     *            待修改数据
     * @return java.lang.Integer
     * @author tanghongjun
     * @since 2020-06-19 15:34:59
     **/
    @Override
    public Integer updateByKey(MsgAliTemplate msgAliTemplate) {

        if (Objects.isNull(msgAliTemplate.getAlipayTempId())) {
            log.error("[{}],根据id修改数据,msgAliTemplate为null", TAG);
            return null;
        }
        return msgAliTemplateDao.updateByKey(msgAliTemplate);
    }

    /**
     * 描述: 新增数据
     *
     * @param msgAliTemplate
     *            待新增数据
     * @return java.lang.Integer 主键key
     * @author tanghongjun
     * @since 2020-06-19 15:34:59
     **/
    @Override
    public Integer insert(MsgAliTemplate msgAliTemplate) {

        if (Objects.isNull(msgAliTemplate)) {
            log.error("[{}],新增数据,msgAliTemplate为null", TAG);
            return null;
        }
        return msgAliTemplateDao.insert(msgAliTemplate);
    }

}